<?php
/*
 * @Author: 笔青居
 * @Date: 2018-10-31 14:57:46
 * @lastEditors: 白酒煮饭
 * @LastEditTime: 2019-11-11 20:56:29
 * @Description: 在笔青居代码的基础上增加接收参数功能
 */
$arr = $_FILES["file"];
$id = $_GET['user'];
function mdir($name)
    {
        $subdir = "./AutoJs_Code/" . $name;
        if (!is_dir($subdir)) {
            mkdir($subdir, 0777, true);
        }
        return $subdir;
}
function gbkToUtf8($s){
    if(false){
        return iconv('gbk','utf-8',$s);
    }
    return $s;
}

if ($arr["size"] < 10241000) {
$arr["tmp_name"];
$fu = "./AutoJs_Code/".mdir($id);
$filename = "./AutoJs_Code/".$id."/".$arr["name"];
if (file_exists(gbkToUtf8($filename))) {
print_r(json_encode(array("code"=>202,"msg"=>"该文件已存在!")));
}
else
{
print_r(json_encode(array("code"=>200,"msg"=>"上传成功!")));
move_uploaded_file($arr["tmp_name"], gbkToUtf8($filename));
}
}
else
{
print_r(json_encode(array("code"=>201,"msg"=>"上传错误，请重试->"+$_FILES["file"]["error"])));
}
?>